<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <img src="./flower.jpg" alt="">
    <script>
    let img = document.querySelector("img");
    let iframe = document.createElement("iframe")
    iframe.name="fi"
    iframe.style.display ="none";
    iframe.src = img.src;
    document.body.appendChild(iframe);
    iframe.onload = function saveImg(){
        window.frames["fi"].document.execCommand("SaveAs");
    }
    </script>
</body>
</html>